package com.hinnotek.amoeba.viewmodels


import androidx.lifecycle.viewModelScope
import com.hinnotek.amoeba.bean.old.*
import com.hinnotek.amoeba.repo.ManageRepo
import com.lee.common.base.BaseViewModel
import com.lee.common.network.net.StateLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class ManageViewModel @Inject constructor(private val repository: ManageRepo):BaseViewModel() {

    private val amountAllocatedData = StateLiveData<MutableList<AmountAllocatedBean>>()
    private val statisticalRDProjectData = StateLiveData<MutableList<StatisticalCustomerProjectBean>>()
    private val sysOrgDetailByIdListData = StateLiveData<MutableList<StatisticalRDProjectBean>>()
    private val sysOrgAmibaDetailListData = StateLiveData<MutableList<SysOrgAmibaDetailListBean>>()
    private val sysOrgDetailByIdData = StateLiveData<SysOrgDetailByIdBean>()
    private val versionData = StateLiveData<VersionBean>()

    fun getSysOrgAmibaList(): StateLiveData<MutableList<AmountAllocatedBean>> {
        viewModelScope.launch {
            repository.getSysOrgAmibaList(amountAllocatedData)
        }
        return amountAllocatedData
    }

    fun getAmibaCustomerDetail(orgId: Int):StateLiveData<MutableList<StatisticalCustomerProjectBean>> {
        viewModelScope.launch {
            repository.getAmibaCustomerDetail(orgId,statisticalRDProjectData)
        }
        return statisticalRDProjectData
    }

    fun getAmibaProjectDetail(orgId: Int) :StateLiveData<MutableList<StatisticalRDProjectBean>>{
        viewModelScope.launch {
            repository.getAmibaProjectDetail(orgId,sysOrgDetailByIdListData)
        }
        return sysOrgDetailByIdListData
    }

    fun getSysOrgAmibaDetailList() :StateLiveData<MutableList<SysOrgAmibaDetailListBean>>{
        viewModelScope.launch {
            repository.getSysOrgAmibaDetailList(sysOrgAmibaDetailListData)
        }
        return sysOrgAmibaDetailListData
    }

    fun getSysOrgDetailById(orgId: Int):StateLiveData<SysOrgDetailByIdBean> {
        viewModelScope.launch {
            repository.getSysOrgDetailById(orgId,sysOrgDetailByIdData)
        }
        return sysOrgDetailByIdData
    }

    fun getNewUpdateVersion() :StateLiveData<VersionBean>{
        viewModelScope.launch {
            repository.getNewUpdateVersion(versionData)
        }
        return versionData
    }


}